package company.meituan;

import java.util.Scanner;

/**
 * 第一题
 *
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-07 10:13
 */
public class M4 {


    static int[][] links;
    static int step = 0;
    static int[] visit;
    static int max;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int N = scanner.nextInt();
            //使用邻接矩阵
            links = new int[N][N];
            visit = new int[N]; //存储访问
            for (int i = 0; i < N-1; i++) {
                int x = scanner.nextInt();
                int y = scanner.nextInt();
                links[x-1][y-1] = 1;
                links[y-1][x-1] = 1;
            }
            dfs(0,1);
            System.out.println(step - max);
        }
    }

    /**
     * max统计的是最长边的长度
     * step 统计的是，走完所有的结点，回到起点，则是所有的边都走了两次
     * step - max 即表示  除了最长边，其他边都走了两次
     */



    public static void dfs(int node,int dept){
        step++;
        visit[node] = 1;
        max = Math.max(dept,max);
        for (int i = 0; i < visit.length; i++) {
            if (links[node][i] == 1 && visit[i] == 0){
                dfs(i,dept+1);
                step++;
            }
        }

    }
}
